class RenameDbFields < ActiveRecord::Migration
  def self.up
    # Change the name of the column 'type', which is a reserved word, for 'kind'. The data type changes to string for simplicity. 
    add_column    :questions , :kind    , :string
    execute("UPDATE questions SET kind = type")
    remove_column :questions , :type
    # Change the name of the column 'scoring' for 'score'
    rename_column :answers, :scoring, :score
    
  end

  def self.down
    rename_column :answers, :score, :scoring
    add_column    :questions , :type    , :decimal
    execute("UPDATE questions SET type = kind")
    remove_column :questions , :kind
  end
end
